package com.magold.logic.polygon;

import org.andengine.entity.scene.Scene;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.magold.logic.ISpriteLogic;
import com.magold.logic.LogicPhysicsHelper;
import com.magold.logic.LogicSpriteWrapper;
import com.magold.sprite.CircleSprite;
import com.magold.sprite.IMultiTextureSprite;


public class CircleShape extends PrimitiveShape {
	protected float mRadius;
	
	public CircleShape(float pRadius) {
		mRadius = pRadius;
	}

	@Override
	public void createPhysicsData(PhysicsWorld pWorld, BodyType pBodyType, FixtureDef pFixtureDef) {
		Body body = PhysicsFactory.createCircleBody(pWorld, mSprite, pBodyType, pFixtureDef);
		mConnector = LogicPhysicsHelper.connectBody(pWorld, body, mSprite);
	}
	
	@Override
	public void createSceneData(float pX, float pY, float pRotation, float pScale, Scene pScene, ISpriteLogic pLogic, ITiledTextureRegion pRegion, VertexBufferObjectManager vbom) {
		pRegion = pRegion.deepCopy();
		pRegion.setTextureSize(mRadius*2, mRadius*2);
		IMultiTextureSprite raw = new CircleSprite(pX, pY, mRadius, pRegion, vbom);
		mSprite = LogicSpriteWrapper.wrap(raw, pScale, null, pLogic, pRotation, pScene);
	}

}
